#include <stdio.h>
#include <sys/types.h>
#include <regex.h>

static char content[] = "Uploaded successful, 43265355921de9a45fc229abed8fd482 (153377 bytes)";

int	main(int argc, char **argv) {
    
    char *exp = "[0-9a-z]{32}";

    regex_t reg = {0};

    int rc;
    rc = regcomp(&reg, exp, REG_EXTENDED | REG_NEWLINE);
    if (rc != 0) {
        char message[256];
        // regerror(int __errcode, const regex_t *restrict __preg, char *restrict __errbuf, size_t __errbuf_size)
        regerror(rc, &reg, message, 256);
        printf(">> %s\n", message);
        return 1;
    }

    size_t matchs = 2;
    regmatch_t match[matchs];

    char *match_text = content;

    rc = regexec(&reg, match_text, matchs, match, 0);
    if (rc != 0) {
        char message[256];
        regerror(rc, &reg, message, 256);
        printf(">>> %s\n", message);
        return 1;
    }

    // printf("%.*s, so = %d, eo = %d\n", match[0].rm_eo - match[0].rm_so, match_text + match[0].rm_so, match[0].rm_so, match[0].rm_eo);
    // printf("%.*s, so = %d, eo = %d\n", match[1].rm_eo - match[1].rm_so, match_text + match[1].rm_so, match[1].rm_so, match[1].rm_eo);

    printf("%.*s\n", match[0].rm_eo - match[0].rm_so, match_text + match[0].rm_so);

    return 0;
}